Repository navigation
Add integration tests for Go To Definition - #5983
Conversation
a16bb90 to
f69b60a
Compare
NTaylorMullen
left a comment
There was a problem hiding this comment.
Very cool to see this all come together and how human readable it all is.
ryanbrandenburg
left a comment
There was a problem hiding this comment.
The code looks really good, just a couple of quibbles about specifics what we'll want Sam's input on. I think I'll write a README for this project with some do's and don'ts if Sam confirms what I said about DTE, cause otherwise it'll be pretty had for people to know that kind of stuff.
How did you find working on it? You certainly got it done faster than I thought so hopefully that means it was breezy? Did you have any suggestions/complaints for either the Framework or this project?
| { | ||
| var dte = await GetRequiredGlobalServiceAsync<SDTE, EnvDTE.DTE>(cancellationToken); | ||
|
|
||
| return dte.ActiveWindow.Caption == windowTitle; |
There was a problem hiding this comment.
I think it would be better if we were able to do like view.ActiveWindow_Changed += ... so we're doing less busy-waiting, but such an API might not exist.
There was a problem hiding this comment.
I couldn't even see a way to get the filename/window title from the active view :(
There was a problem hiding this comment.
Yeah I figured that was probably the case but wanted to be sure.
There was a problem hiding this comment.
I couldn't even see a way to get the filename/window title from the active view :(
TestServices.Shell.GetActiveWindowCaptionAsync. And it doesn't use DTE.
|
@ryanbrandenburg Updated with your "wait for classification in initialize" idea, if you want to have another look. Also added a version check instead of skipping that one test, curious to see if it works in CI :) |
ryanbrandenburg
left a comment
There was a problem hiding this comment.
This looks great! I'd like to get @sharwell's review to make sure that we're staying on the "Golden Path" WRT DTE usage.
| public async Task GoToDefinition_ComponentAttribute() | ||
| { | ||
| var version = await TestServices.Shell.GetVersionAsync(HangMitigatingCancellationToken); | ||
| if (version < new System.Version(17, 1, 32113, 165)) |
There was a problem hiding this comment.
Filed microsoft/vs-extension-testing#101. I think this'd be nice to have as part of the framework. Maybe instead of returning ("Success") we should do Assert.Ignore("Wrong VS Version"); so we know the test didn't really run.
There was a problem hiding this comment.
Thank you! I was looking for Assert.Inconclusive but didn't notice Ignore.
There was a problem hiding this comment.
Nope. no Assert.Ignore in xUnit 😛
| { | ||
| await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
|
|
||
| var dte = await GetRequiredGlobalServiceAsync<SDTE, EnvDTE.DTE>(cancellationToken); |
There was a problem hiding this comment.
💡 DTE should be avoided where possible. In this case, use IOleCommandTarget:
var dispatcher = await GetRequiredGlobalServiceAsync<SUIHostCommandDispatcher, IOleCommandTarget>(cancellationToken);
ErrorHandler.ThrowOnFailure(dispatcher.Exec(commandGuid, commandId, (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero));There was a problem hiding this comment.
DTE should be avoided where possible
Is there a quick summary as to why?
There was a problem hiding this comment.
In the best case, it's slow. In the worst case, it's broken/outdated/legacy.
DTE is a legacy automation wrapper around other public APIs. The first step to moving to modern APIs is to unwrap the calls so we can understand the true underlying APIs involved.
|
Mergin'. Follow up can always come in a follow up. I suspect that's why they call it that. |
Fixes #5957